<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 16/4/20
 * Time: 下午8:28
 */
class SiteService extends Service {
	
	//用户渠道权限
	public static function getOS($user){
		$modChannel = new ModChannel();
		$game = PubBase::getCurrentGame();
		$params = array();
		$params['g'] = $game;
		$channel = $modChannel->select($params);
		$options = array();
		if($user['IsAdmin'] == 1 || $user['ViewAllChannel'] == 2){  //超级管理员或者ViewAllChannel=2可以查看所有渠道的数据
			foreach ($channel as $key=>$val){
				$options[$val['tab']] = $val['channel_name'];
			}
		}else{
			$params = array();
			$params['user_id'] = $user['UserID'];
			$modUserChannel = new ModUserChannel();
			$userChannel = $modUserChannel->select($params);
			$channel_id_array = array();
			foreach ($userChannel as $key=>$val){
				$channel_id_array[] = $val['channel_id'];
			}
			foreach ($channel as $key=>$val){
				if(in_array($val['id'], $channel_id_array)){
					$options[$val['tab']] = $val['channel_name'];
				}
			}
		}
		return $options;
	}
   
}
